﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace WinCAL
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            statusStrip1.Text = "A comprimir...";
            try
            {
                if (rbHuffman.Enabled)
                    Process.Start("wincal.exe -c -h \"" + openFileDialog1.FileName + "\"");
                else
                    Process.Start("wincal.exe -c -lzw \"" + openFileDialog1.FileName + "\"");
            }
            catch
            {
                MessageBox.Show("Infelizmente, ocorreu um erro.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            statusStrip1.Text = "";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            statusStrip1.Text = "A descomprimir...";
            try
            {
                if (rbHuffman.Enabled)
                    Process.Start("wincal.exe -d -h \"" + openFileDialog1.FileName + "\"");
                else
                    Process.Start("wincal.exe -d -lzw \"" + openFileDialog1.FileName + "\"");
            }
            catch
            {
                MessageBox.Show("Infelizmente, ocorreu um erro.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            statusStrip1.Text = "";
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            button4.Enabled = true;
            textBox2.Enabled = true;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName = "";
            openFileDialog1.ShowDialog();
            textBox1.Text = openFileDialog1.FileName;
            button4.Enabled = true;
            textBox2.Enabled = true;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            saveFileDialog1.FileName = "";
            saveFileDialog1.ShowDialog();
            textBox2.Text = saveFileDialog1.FileName;
        }
    }
}
